<template>
    <div class="qrcode">

    </div>
</template>
<script>
export default {
    name: "qrcode",
    data: function() {
        return {
            model: {},
            multipleSelection: []
        }
    },
    methods: {
        printQR: function() {
            //此处为选择后的文件
            console.log(this.multipleSelection.length, 'this.multipleSelection')
            this.multipleSelection.map((item, i) => {
                document.write('<div style="margin:10px;border:1px solid black; float:left">'
                    + '<div id="qrcode' + i + '"></div>'
                    + '<div style="margin-left: 10px;margin-top: 5px;">仪器编码：' + item.instrumentCode + '</div>'
                    + '<p style="margin-left: 10px;width:230px;margin-bottom: 0;margin-top: 0;height:43px;">终端：' + item.terminal + '</p>'
                    + '</div>'
                );
                var qrcode = new QRCode(document.getElementById('qrcode' + i), {
                    text: item.instrumentCode,
                    width: 240,
                    height: 240,
                    colorDark: '#000000',
                    colorLight: '#ffffff',
                    correctLevel: QRCode.CorrectLevel.H
                });
            });
            window.print();
        },
        initList: function() {
            this.$http.post('api/assignment/getQrcodeList').then(res => {
                let result = res.data;
                if (result.code == 100) {
                    this.multipleSelection = result.data.content;
                    this.printQR();
                }
            });
        }
    },
    created: function() {
        this.initList();
    }
}
</script>